# @Time  : 2021/7/28 9:35
# @Author: zhanfengzhen
# @Email : zhanfengzhen@126.com
# @File  : contactPage.py
# !/usr/bin/env python
# -*- coding: UTF-8 -*-
from time import sleep

from selenium.webdriver.common.by import By

from hogwarts.HogwartsHomework.webautomationWork2.po.add_departmentPage import AddDepartmentPage
from hogwarts.HogwartsHomework.webautomationWork2.po.basePage import BasePage


class ContactPage(BasePage):
    #加号
    _ADD = (By.CSS_SELECTOR, '.member_colLeft_cntWrap .js_create_dropdown:nth-child(2)')
    #添加部门
    _ADDDEPARTMENT = (By.CSS_SELECTOR, '.js_create_dropdown_container>li>.js_create_party')
    #部门列表
    _ADPLIST = (By.XPATH, '//*[@class="jstree-anchor"]')

    def goto_departmentPage(self):
        self.wait_click(self._ADD)
        self.wait_click(self._ADDDEPARTMENT)
        return AddDepartmentPage(self.dri)

    def departement_list(self):
        self.dri.refresh()
        sleep(3)
        list = self.finds(*self._ADPLIST)  #//*[@aria-level="2"]
        ll = []
        for x in list:
            ll.append(x.text)
        return ll
